package com.applications.codemash.utility.parser;

import java.util.ArrayList;
import java.util.List;

import android.sax.EndTextElementListener;
import android.sax.RootElement;
import android.util.Xml;

import com.applications.codemash.core.Constants;

public class TwitterParser extends BaseFeedParser<String>
{
	public TwitterParser(String requestUrl)
	{
		super(requestUrl);
	}

	@Override
	public List<String> parse()
	{
		RootElement root = new RootElement(Constants.TWITTER_USER_ELEMENT);
		final List<String> list = new ArrayList<String>();
			
		root.getChild(Constants.TWITTER_USER_PROFILE_IMAGE_ELEMENT).setEndTextElementListener(new EndTextElementListener() {
			@Override
			public void end(String body)
			{
				body = body.replace("normal", "bigger");
				list.add(body);
			}
		});
		
		try
		{
			Xml.parse(getInputStream(), Xml.Encoding.UTF_8, root.getContentHandler());
		}
		catch (Exception ex)
		{
			throw new RuntimeException(ex);
		}
		
		return list;
	}

}
